require(['init'], function () {
    var $pagination = $('#js-pagination')
    var pagination
  //获取当前的id
  var userid="",currentid="";
  $.ajax({
    url: ' /api/user/current',
    type: 'get',
    async:false,
    success:function(data){
      userid = data.data.userid;

     }
   });
   $.ajax({
     url: '/api/teacher/user/' + userid,
     type: 'get',
     async:false,
     success:function(json){
      currentid = json.data.teacheruid //当前老师的id
     }
    })
  function getstudentjob(querystr, cb) {
    $.ajax({
      url: '/api/task/'+currentid+'/classes',
      type:'get',
        data:querystr,
      success: function (data) {
          // cb && cb(data);后台没有进行修改
        var $listTable = $('#teacher_class').html('');
        if(data.data.length==0){
          $listTable.hide();
          $('.teacher_class').hide();
          $('.data-no').show();

        }else{
          $listTable.show();
          $('.teacher_class').show();
          $('.data-no').hide()
          $thead=$('<thead>\
          <tr>\
            <th >'+i18next.t('table.no')+'</th>\
            <th >'+i18next.t('table.classname')+'</th>\
            <th >'+i18next.t('table.coursetype')+'</th>\
            <th >'+i18next.t('table.productname')+'</th>\
            <th >'+i18next.t('table.handle')+'</th>\
          </tr>\
        </thead>').appendTo($listTable)
      var $tbody=$('<tbody></tbody>').appendTo($listTable)
     $.each(data.data,function(index,item){
        $('<tr></tr>').appendTo($tbody);
        var $tr=$('<tr></tr>').appendTo($tbody);
        $tr.append('<td>'+(index+1)+'</td>');
        $tr.append('<td>'+item.classe+'</td>');
        var $classname=$('<td></td>').appendTo($tr);
        $tr.append('<td>'+item.product+'</td>');
        var $operation=$('<td></td>').appendTo($tr);
        $publish_job=$('<a class="btn btn-primary btn-sm btn-inverse ml5" href="teacher_class_lesson.html?type='+item.type+'&classeid='+item.classeid+'&classe='+item.classe+'">'+i18next.t('table.details')+'</a>').appendTo($operation);
        if(item.type==1){
          $('<a>'+i18next.t('table.aboutclass')+'</a>').appendTo($classname)
        }else if(item.type==2){
          $('<a>'+i18next.t('table.classclass')+'</a>').appendTo($classname)
         }
       })
      }
     }
   })
 }
 // getstudentjob();
    pagination = new Pagination($pagination, getstudentjob)
})
